<template>
  <a-config-provider :locale="locale">
    <div id="app">
      <router-view />
    </div>
  </a-config-provider>
</template>

<script>
import { domTitle, setDocumentTitle } from '@/utils/domUtil'
import { i18nRender } from '@/locales'

export default {
  data() {
    return {}
  },
  computed: {
    locale() {
      // 只是为了切换语言时，更新标题
      const { title } = this.$route.meta
      title && setDocumentTitle(`${i18nRender(title)} - ${domTitle}`)

      return this.$i18n.getLocaleMessage(this.$store.getters.lang).antLocale
    },
  },
  watch: {
    // 监听路由配合WFStore解决同个页面切换组件回退问题
    $route(to, from) {
      if (to.name === 'NewsTypes') {
        if (to.query.isShow == 1) {
          this.$store.commit('changeTypes', false)
        } else {
          this.$store.commit('changeTypes', true)
        }
      }
      if (to.name === 'NewsList') {
        if (to.query.isShow2 == 1) {
          this.$store.commit('changeTypes2', false)
        } else {
          this.$store.commit('changeTypes2', true)
        }
      }
    },
  },
}
</script>
